package statistics;

import java.util.Random;


public class UniformDistribution extends Distribution{

    protected double a;
    protected double b;
    
    public UniformDistribution( double a , double b, Random random ){
        this.a = a;
        this.b = b;
    }
            

    public double expectation() {
       return (a+b)/2;
    }


    public double variance() {
        return (b-a)*(b-a)/12;
    }


    public double nextRandom() {
        double u = random.nextDouble();
        return a+(b-a)*u;
    }
    
    
}